package com.fs.service.impl;


import com.fs.dao.NoticeDao;
import com.fs.pojo.Notice;
import com.fs.service.NoticeService;
import com.fs.utils.BeanFactories;
import com.fs.utils.IdWorker;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * (TbNotice)表服务实现类
 *
 * @author makejava
 * @since 2022-11-15 10:21:17
 */

public class NoticeServiceImpl implements NoticeService {
    private NoticeDao bean = BeanFactories.getBean(NoticeDao.class);

    @Override
    public List<Notice> getAllNoticeOfClass(String classId) {

        return bean.queryByClass(classId);
    }

    @Override
    public int deleteById(String id) {
        return bean.deleteById(id);
    }

    @Override
    public List<Notice> getNoticeByTitle(String title, String classId) {
        return bean.queryByTitle(title,classId);
    }

    @Override
    public int addNotice(Notice notice) {
        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        notice.setTime(sdf.format(new Date()));
        IdWorker id =  new IdWorker();
        notice.setId(""+id.nextId());
        return bean.insert(notice);
    }
}
